package com.ling.pl.security.model;

import com.ling.pl.core.commons.constant.TablePreDef;
import com.ling.pl.core.model.impl.BaseEntity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

/**
 * 角色资源
 *
 * @author bo.wang
 * @version 1.0.0
 * @create 2016年3月15日 下午3:27:51
 */
@Entity
@Table(name = RoleResource.TABLE)
public class RoleResource extends BaseEntity {

    public static final String TABLE = TablePreDef.BASEPRE + "ROLE_RESOURCE";
    public static final String SEQ = TABLE;

    @Id
    @Column(name = "ROLE_RESOURCE_ID", length = 36)
    String id;

    @Column(name = "ROLE_ID", length = 36)
    String roleId;

    @Column(name = "URL_ID", length = 36)
    String urlId;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getRoleId() {
        return roleId;
    }

    public void setRoleId(String roleId) {
        this.roleId = roleId;
    }

    public String getUrlId() {
        return urlId;
    }

    public void setUrlId(String urlId) {
        this.urlId = urlId;
    }

//    @Override
//    public Serializable getBusinessId() {
//        return getId();
//    }

//    @Override
//    public String toLogString(String operationType, Log log) {
//        ///todo
//        IDao dao = SpringUtil.getBean(BaseDao.BEAN_ID);
//        String logInfo = " 关系如下:";
//        if (getRoleId() != null) {
//            if (dao != null) {
//                DefaultRole role = (DefaultRole) dao.get(DefaultRole.class, getRoleId());
//                if (role != null) {
//                    logInfo = logInfo + " 角色名:" + role.getName();
//                }
//            }
//            logInfo = logInfo + " 角色id:" + getRoleId();
//        }
//        if (getUrlId() != null) {
//            if (dao != null) {
//                DefaultUrl url = (DefaultUrl) dao.get(DefaultUrl.class, getUrlId());
//                if (url != null) {
//                    logInfo = logInfo + " 菜单名:" + url.getName() + " 菜单地址:" + url.getUrl();
//                }
//            }
//            logInfo = logInfo + " 菜单id:" + getUrlId();
//        }
//        return logInfo;
//    }
}
